<?php
 
 
namespace app\index\controller;

use think\Controller;
use think\Db;
use think\Session;
/**
 * 个人中心 手机端 控制器
 *
 * 2018-11-3
 *
 * @author 小雨
 *
 */
class User extends Controller
{
    
    public function index()
    {
    	$user= Session::get("user");
    	switch ($user['power']) {
    		case '1':
    			$user['info'] = "股东";
    			break;
    		case "2":
    			$user['info'] = "团队";
    			break;
    	}
    	if($user['level'] == 2 && $user['power'] == 0){
    		$user['info'] = "合伙人";
    	}
    	$info = $this->yj_tree($user['uid']);
    	$bank = $this->child_tree($info['type'],$user['uid']);
    	$yj_sum = 0;
    	for($a=0;$a<$info['type'];$a++){
    			foreach ($bank[$a] as $key => $value) {
    				switch ($a) {
    					case '0':
    						$yj_sum+= $info['bank'][$value['bank_name']]['one'];
    						break;
    						case '1':
    						$yj_sum+= $info['bank'][$value['bank_name']]['two'];
    						break;
    						case '2':
    						$yj_sum+= $info['bank'][$value['bank_name']]['three'];
    						break;
    			
    				}
    				
    			}
    	}
    	$sql = "select sum(money) as sum  from ims_xuan_zy_tixian where  status = 0 and uid ='{$user['uid']}'";
    	$sq_sum = DB::query($sql)[0]['sum'];

    	$sql = "select sum(money) as sum  from ims_xuan_zy_tixian where  status in (1,4,5) and uid ='{$user['uid']}'";
    	$tx_sum = DB::query($sql)[0]['sum'];
    	// 订单列表
    	$sql = "select count(*) as count , status from ims_xuan_zy_bankorder where user_id = '{$user['uid']}' group by status";
    	$order = DB::query($sql);
    	$this->assign("yj_sum",$yj_sum.".00");
    	$this->assign("sq_sum",$sq_sum);
    	$this->assign("tx_sum",$tx_sum);
    	$this->assign("user",$user);
    	$this->assign("order",$order);
        return $this->fetch();
    }
}

